public class Sloution {
    public int[] rotate(int[] nums, int k) {
        int[] num = nums.clone();
        int len = nums.length;
        int count = 0;
        for(int i = 0;i < len;i++){
            int len1 = len - k;
            if(k == 0){
                if(count != len1)
                    nums[i] = num[count];
                count++;
            }
            if(len == 1){
                break;
            }
            if(k > len){
                nums[i] = num[len -1 - i];
            }
            if(k != 0 && len > k){
                nums[i] = num[len1];
                k--;
            }



        }
        return nums;
    }
    public void print(int[] nums){
        for (int x : nums){
            System.out.print(x + " ");
        }
    }
}
